package com.zxt.content.user.controller;

import com.zxt.content.common.Bean.Result;
import com.zxt.content.user.req.LifeLogDTO;
import com.zxt.content.user.resp.LifeLogVO;
import com.zxt.content.user.service.LifeLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zxt
 */
@Slf4j
@RequestMapping("/life/lifeLog")
@RestController
@AllArgsConstructor
@Api(tags = "生活日志管理接口")
public class LifeLogController {

    private final LifeLogService lifeLogService;

    @GetMapping("/list")
    @ApiOperation(value = "生活日志列表", notes = "生活日志列表")
    private Result<List<LifeLogVO>> list() {
        return Result.newSuccess(lifeLogService.list());
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增事件记录", notes = "新增事件记录")
    private Result add(@RequestBody @Validated LifeLogDTO dto) {
        lifeLogService.add(dto);
        return Result.newSuccess();
    }
}
